#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+100;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
bool solve(string a,string b){
    if(a.size()==1&&b.size()==1){
        if(a!=b) return false;
        else return true;
    }
    if(a==b){
        return true;
    }
    if(a.size()&1||b.size()&1) return false;
    if(a.size()!=b.size()) return false;
    else{
        LL mid=a.size()/2;
        string la="";string ra="";
        string lb="";string rb="";
        for(LL i=0;i<mid;i++) la+=a[i],lb+=b[i];
        for(LL i=mid;i<a.size();i++) ra+=a[i],rb+=b[i];

        LL ans1=solve(la,lb);
        if(ans1==true){
            LL ans2=solve(ra,rb);
            if(ans2==true) return true;
        }
        else{
            LL ans3=solve(la,rb);
            if(ans3==true){
                LL ans4=solve(ra,lb);
                if(ans4==1){
                    return true;
                }
            }
        }
        return false;
    }
}
int main(void)
{
  ///cin.tie(0);std::ios::sync_with_stdio(false);
  string s1="";string s2="";
  cin>>s1;cin>>s2;
  if(s1.size()!=s2.size()){
    cout<<"NO"<<"\n";
    return 0;
  }
  LL t=solve(s1,s2);
  if(t==1){
    cout<<"YES"<<"\n";
  }
  else cout<<"NO"<<"\n";
return 0;
}
